//
//  RegisterViewController.m
//  XingMei
//
//  Created by 钱金军 on 2019/3/20.
//  Copyright © 2019年 钱金军. All rights reserved.
//

#import "RegisterViewController.h"
#import "FilesHeader.h"

@interface RegisterViewController ()


@property (nonatomic,strong) YanZhengMaBtn *yanZheng;
/** 是否点击 */
@property (nonatomic ,assign) BOOL selected;


@end

@implementation RegisterViewController{
    UIButton *chooseBtn, *agreementBtn;
    UITextField *refereesText, *phoneText, *validationCodeText, *passwordText;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setNavBackgroundImageTitleText:@"注册"];
    [self setBackView];
    [self setOperationBtn];
}

- (void)setBackView{
    NSArray *imgArr = [NSArray arrayWithObjects:@"register_icon_1",@"register_icon_6",@"register_icon_3",@"register_icon_2", nil];
    NSArray *titleArr = [NSArray arrayWithObjects:@"推荐人",@"手机号",@"验证码",@"密码", nil];
    
    for (int i = 0; i < imgArr.count; i++) {
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(50, Height_NavBar + 70 + i*35, 15, 15)];
        imgView.image = [UIImage imageNamed:imgArr[i]];
        [self.view addSubview:imgView];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(imgView.right + 7, imgView.top, 50, 15)];
        label.text = titleArr[i];
        label.textColor = rgba(51, 51, 51, 1);
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [UIFont fontWithName:ZhongDeng size:14];
        [self.view addSubview:label];

        UITextField *text = [[UITextField alloc] initWithFrame:CGRectMake(label.right + 10, label.top, KScreenWidth-label.right-70, label.frame.size.height)];
        text.layer.borderColor = [UIColor clearColor].CGColor;
        text.font = [UIFont fontWithName:ZhongDeng size:14];
        [self.view addSubview:text];

        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(label.right, text.bottom + 10, KScreenWidth-label.right-50, 1)];
        line.backgroundColor = rgba(232, 232, 232, 1);
        [self.view addSubview:line];
        
        if (i == 0) {
            refereesText = text;
        }else if (i == 1){
            phoneText = text;
        }else if (i == 2){
            validationCodeText = text;
        }else if (i == 3){
            passwordText = text;
        }
        
        if (i == 2) {
            text.frame = CGRectMake(label.right + 10, label.top, KScreenWidth-label.right-70, label.frame.size.height);
            //手机验证码
            self.yanZheng = [YanZhengMaBtn buttonWithType:UIButtonTypeCustom];
            self.yanZheng.frame = CGRectMake(3, 2, 40, text.frame.size.height);
            [self.yanZheng setTitle:@"获取" forState: UIControlStateNormal ];
            [self.yanZheng setTitleColor:rgba(255, 138, 10, 1) forState:UIControlStateNormal];
            self.yanZheng.titleLabel.font=[UIFont systemFontOfSize:14];
            self.yanZheng.backgroundColor = [UIColor whiteColor];
            self.yanZheng.DaoJiShitime=60;
            self.yanZheng.enabled=YES;
            self.yanZheng.againColor=[UIColor clearColor];
            [self.yanZheng addTarget:self action:@selector(sendCord) forControlEvents:UIControlEventTouchUpInside];
            self.yanZheng.layer.borderColor = rgba(255, 138, 10, 1).CGColor;
            self.yanZheng.layer.borderWidth = 1;
            
            text.rightViewMode = UITextFieldViewModeAlways;
            text.rightView = self.yanZheng;
        }else if (i == 3){
            chooseBtn = [[UIButton alloc] initWithFrame:CGRectMake(imgView.left, line.bottom + 13, 15, 15)];
            [chooseBtn setImage:[UIImage imageNamed:@"register_icon_4"] forState:UIControlStateNormal];
            [self.view addSubview:chooseBtn];
            [chooseBtn addTarget:self action:@selector(clickChoose) forControlEvents:UIControlEventTouchUpInside];
            
            UIButton *agreementBtn = [[UIButton alloc] initWithFrame:CGRectMake(chooseBtn.right + 5, chooseBtn.top, 70, 13)];
            [agreementBtn setTitle:@"注册协议" forState:UIControlStateNormal];
            [agreementBtn setTitleColor:rgba(255, 116, 2, 1) forState:UIControlStateNormal];
            agreementBtn.titleLabel.font = [UIFont fontWithName:ZhongDeng size:13];
            [self.view addSubview:agreementBtn];
            [agreementBtn addTarget:self action:@selector(clickCheckagreement) forControlEvents:UIControlEventTouchUpInside];
        }
    }
}

- (void)setOperationBtn{
    /** 注册 */
    UIButton *registeredBtn = [[UIButton alloc] initWithFrame:CGRectMake(48, chooseBtn.bottom + 15, KScreenWidth-96, 45)];
    [registeredBtn setBackgroundImage:[UIImage imageNamed:@"register_img_10"] forState:UIControlStateNormal];
    [registeredBtn setTitle:@"注册" forState:UIControlStateNormal];
    [registeredBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    registeredBtn.layer.cornerRadius = 22;
    [self.view addSubview:registeredBtn];
    [registeredBtn addTarget:self action:@selector(clickRegistered) forControlEvents:UIControlEventTouchUpInside];
    
    /** 忘记密码 */
    UIButton *forgetPassword = [[UIButton alloc] initWithFrame:CGRectMake(registeredBtn.left + 15, registeredBtn.bottom + 17, 70, 12)];
    [forgetPassword setTitle:@"忘记密码？" forState:UIControlStateNormal];
    [forgetPassword setTitleColor:rgba(255, 116, 2, 1) forState:UIControlStateNormal];
    forgetPassword.titleLabel.font = [UIFont fontWithName:ZhongDeng size:12];
    [self.view addSubview:forgetPassword];
    [forgetPassword addTarget:self action:@selector(clickForgetPassword) forControlEvents:UIControlEventTouchUpInside];
    
    /** 登录 */
    UIButton *loginBtn = [[UIButton alloc] initWithFrame:CGRectMake(registeredBtn.right - 50, forgetPassword.top, 35, forgetPassword.frame.size.height)];
    [loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [loginBtn setTitleColor:rgba(51, 51, 51, 1) forState:UIControlStateNormal];
    loginBtn.titleLabel.font = [UIFont fontWithName:ZhongDeng size:12];
    [self.view addSubview:loginBtn];
    [loginBtn addTarget:self action:@selector(clickLogin) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark 获取验证码
- (void)sendCord{
    
}

#pragma mark 点击同意注册协议
- (void)clickChoose{
    _selected = !_selected;
    if(_selected) {
        [chooseBtn setImage:[UIImage imageNamed:@"register_icon_5"] forState:UIControlStateNormal];
    }else {
        [chooseBtn setImage:[UIImage imageNamed:@"register_icon_4"] forState:UIControlStateNormal];
    }
    
}

#pragma mark 点击查看注册协议
- (void)clickCheckagreement{
    CheckAgreementViewController *checkAgreement = [[CheckAgreementViewController alloc] init];
    checkAgreement.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:checkAgreement animated:YES completion:nil];
}

#pragma mark 点击注册
- (void)clickRegistered{
    
}

#pragma mark 点击忘记密码
- (void)clickForgetPassword{
    ForgotPasswordViewController *forgotPassword = [[ForgotPasswordViewController alloc] init];
    forgotPassword.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:forgotPassword animated:YES completion:nil];
}

#pragma mark 点击登录
- (void)clickLogin{
    
}




















@end
